﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Data;

namespace QLChoDiaOc.Process
{
    class ShowInfo
    {
        QLChoDiaOcEntities m_entities = new QLChoDiaOcEntities();
        SelectInfo _selectInfo = new SelectInfo();
        ListInfo _listInfo = new ListInfo();
        OtherHandle _otherHandle = new OtherHandle();
        
        public void ShowListKhachHang(DataGrid _dataKhachHang)
        {
            //_dataKhachHang.ItemsSource = _listInfo.ListKhachHang();

            List<KHACHHANG> dsKhachHang = new List<KHACHHANG>();
            for (int i = 0; i < _listInfo.ListKhachHang().Count; i++)
            {
                KHACHHANG _khachHangTemp = new KHACHHANG();

                _khachHangTemp.MaKH = _listInfo.ListKhachHang()[i].MaKH;
                _khachHangTemp.HoTen = _listInfo.ListKhachHang()[i].HoTen;
                _khachHangTemp.NgaySinh = _listInfo.ListKhachHang()[i].NgaySinh;
                _khachHangTemp.DiaChi = _listInfo.ListKhachHang()[i].DiaChi;
                _khachHangTemp.Email = _listInfo.ListKhachHang()[i].Email;
                _khachHangTemp.SoDT = _listInfo.ListKhachHang()[i].SoDT;

                dsKhachHang.Add(_khachHangTemp);
            }
            _dataKhachHang.ItemsSource = dsKhachHang;
        }

        public void ShowListKhachHang(DataGrid _dataKhachHang, string MaKH)
        {
            //_dataKhachHang.ItemsSource = _listInfo.ListKhachHang();

            List<KHACHHANG> dsKhachHang = new List<KHACHHANG>();
            for (int i = 0; i < _listInfo.ListKhachHang(MaKH).Count; i++)
            {
                KHACHHANG _khachHangTemp = new KHACHHANG();

                _khachHangTemp.MaKH = _listInfo.ListKhachHang(MaKH)[i].MaKH;
                _khachHangTemp.HoTen = _listInfo.ListKhachHang(MaKH)[i].HoTen;
                _khachHangTemp.NgaySinh = _listInfo.ListKhachHang(MaKH)[i].NgaySinh;
                _khachHangTemp.DiaChi = _listInfo.ListKhachHang(MaKH)[i].DiaChi;
                _khachHangTemp.Email = _listInfo.ListKhachHang(MaKH)[i].Email;
                _khachHangTemp.SoDT = _listInfo.ListKhachHang(MaKH)[i].SoDT;

                dsKhachHang.Add(_khachHangTemp);
            }
            _dataKhachHang.ItemsSource = dsKhachHang;
        }

        public void ShowListToBao(DataGrid _dataToBao)
        {
            List<TOBAO> dsToBao = new List<TOBAO>();
            for (int i = 0; i < _listInfo.ListToBao().Count; i++)
            {
                TOBAO _toBaoTemp = new TOBAO();

                _toBaoTemp.MaToBao = _listInfo.ListToBao()[i].MaToBao;
                _toBaoTemp.TenToBao = _listInfo.ListToBao()[i].TenToBao;
                _toBaoTemp.ThuPhatHanh = _listInfo.ListToBao()[i].ThuPhatHanh;
                _toBaoTemp.DonGia = _listInfo.ListToBao()[i].DonGia;

                dsToBao.Add(_toBaoTemp);
            }
            _dataToBao.ItemsSource = dsToBao;
        }

        public void ShowListLoaiDiaOc(DataGrid _dataLoaiDiaOc)
        {
            List<LOAIDIAOC> dsLoaiDiaOc = new List<LOAIDIAOC>();
            for (int i = 0; i < _listInfo.ListLoaiDiaOc().Count; i++)
            {
                LOAIDIAOC _loaiDiaOc = new LOAIDIAOC();
                _loaiDiaOc.MaLoaiDiaOc = _listInfo.ListLoaiDiaOc()[i].MaLoaiDiaOc;
                _loaiDiaOc.TenLoaiDiaOc = _listInfo.ListLoaiDiaOc()[i].TenLoaiDiaOc;

                dsLoaiDiaOc.Add(_loaiDiaOc);
            }
            _dataLoaiDiaOc.ItemsSource = dsLoaiDiaOc;
        }

        public void ShowListLoaiBang(DataGrid _dataLoaiBang)
        {
            List<LOAIBANG> dsLoaiBang = new List<LOAIBANG>();
            for (int i = 0; i < _listInfo.ListLoaiBang().Count; i++)
            {
                LOAIBANG _loaiBang = new LOAIBANG();
                _loaiBang.MaLoaiBang = _listInfo.ListLoaiBang()[i].MaLoaiBang;
                _loaiBang.TenLoaiBang = _listInfo.ListLoaiBang()[i].TenLoaiBang;
                _loaiBang.DonGia = _listInfo.ListLoaiBang()[i].DonGia;

                dsLoaiBang.Add(_loaiBang);
            }
            _dataLoaiBang.ItemsSource = dsLoaiBang;
        }

        public void ShowListDiaOc(DataGrid _dataDiaOc)
        {
            _dataDiaOc.ItemsSource = _listInfo.ListDiaOc();

            List<DIAOC> dsDiaOc = new List<DIAOC>();
            for (int i = 0; i < _listInfo.ListDiaOc().Count; i++)
            {
                DIAOC m_diaoc = new DIAOC();
                m_diaoc.MaDiaOc = _listInfo.ListDiaOc()[i].MaDiaOc;
                m_diaoc.MaKH = _listInfo.ListDiaOc()[i].MaKH;
                m_diaoc.MaLoaiDiaOc = _listInfo.ListDiaOc()[i].MaLoaiDiaOc;
                m_diaoc.SoNha = _listInfo.ListDiaOc()[i].SoNha;
                m_diaoc.Duong = _listInfo.ListDiaOc()[i].Duong;
                m_diaoc.Quan = _listInfo.ListDiaOc()[i].Quan;
                m_diaoc.DienTichDat = _listInfo.ListDiaOc()[i].DienTichDat;
                m_diaoc.DienTichSuDung = _listInfo.ListDiaOc()[i].DienTichSuDung;
                m_diaoc.ViTri = _listInfo.ListDiaOc()[i].ViTri;
                m_diaoc.HuongNha = _listInfo.ListDiaOc()[i].HuongNha;
                m_diaoc.MoTa = _listInfo.ListDiaOc()[i].MoTa;
                m_diaoc.GiaBan = _listInfo.ListDiaOc()[i].GiaBan;
                m_diaoc.TinhTrang = _listInfo.ListDiaOc()[i].TinhTrang;

                dsDiaOc.Add(m_diaoc);
            }
            _dataDiaOc.ItemsSource = dsDiaOc;
        }

        public void ShowListDiaOc(DataGrid _dataDiaOc, int TinhTrang)
        {
            List<DIAOC> dsDiaOc = new List<DIAOC>();
            for (int i = 0; i < _listInfo.ListDiaOc(TinhTrang).Count; i++)
            {
                DIAOC m_diaoc = new DIAOC();
                m_diaoc.MaDiaOc = _listInfo.ListDiaOc(TinhTrang)[i].MaDiaOc;
                m_diaoc.MaKH = _listInfo.ListDiaOc(TinhTrang)[i].MaKH;
                m_diaoc.MaLoaiDiaOc = _listInfo.ListDiaOc(TinhTrang)[i].MaLoaiDiaOc;
                m_diaoc.SoNha = _listInfo.ListDiaOc(TinhTrang)[i].SoNha;
                m_diaoc.Duong = _listInfo.ListDiaOc(TinhTrang)[i].Duong;
                m_diaoc.Quan = _listInfo.ListDiaOc(TinhTrang)[i].Quan;
                m_diaoc.DienTichDat = _listInfo.ListDiaOc(TinhTrang)[i].DienTichDat;
                m_diaoc.DienTichSuDung = _listInfo.ListDiaOc(TinhTrang)[i].DienTichSuDung;
                m_diaoc.ViTri = _listInfo.ListDiaOc(TinhTrang)[i].ViTri;
                m_diaoc.HuongNha = _listInfo.ListDiaOc(TinhTrang)[i].HuongNha;
                m_diaoc.MoTa = _listInfo.ListDiaOc(TinhTrang)[i].MoTa;
                m_diaoc.GiaBan = _listInfo.ListDiaOc(TinhTrang)[i].GiaBan;
                m_diaoc.TinhTrang = _listInfo.ListDiaOc(TinhTrang)[i].TinhTrang;

                dsDiaOc.Add(m_diaoc);
            }
            _dataDiaOc.ItemsSource = dsDiaOc;
        }

        public void ShowListDiaOc(DataGrid _dataDiaOc, string MaDiaOc)
        {
            if (_listInfo.ListDiaOc(MaDiaOc) != null)
            {
                List<DIAOC> dsDiaOc = new List<DIAOC>();
                for (int i = 0; i < _listInfo.ListDiaOc(MaDiaOc).Count; i++)
                {
                    DIAOC m_diaoc = new DIAOC();
                    m_diaoc.MaDiaOc = _listInfo.ListDiaOc(MaDiaOc)[i].MaDiaOc;
                    m_diaoc.MaKH = _listInfo.ListDiaOc(MaDiaOc)[i].MaKH;
                    m_diaoc.MaLoaiDiaOc = _listInfo.ListDiaOc(MaDiaOc)[i].MaLoaiDiaOc;
                    m_diaoc.SoNha = _listInfo.ListDiaOc(MaDiaOc)[i].SoNha;
                    m_diaoc.Duong = _listInfo.ListDiaOc(MaDiaOc)[i].Duong;
                    m_diaoc.Quan = _listInfo.ListDiaOc(MaDiaOc)[i].Quan;
                    m_diaoc.DienTichDat = _listInfo.ListDiaOc(MaDiaOc)[i].DienTichDat;
                    m_diaoc.DienTichSuDung = _listInfo.ListDiaOc(MaDiaOc)[i].DienTichSuDung;
                    m_diaoc.ViTri = _listInfo.ListDiaOc(MaDiaOc)[i].ViTri;
                    m_diaoc.HuongNha = _listInfo.ListDiaOc(MaDiaOc)[i].HuongNha;
                    m_diaoc.MoTa = _listInfo.ListDiaOc(MaDiaOc)[i].MoTa;
                    m_diaoc.GiaBan = _listInfo.ListDiaOc(MaDiaOc)[i].GiaBan;
                    m_diaoc.TinhTrang = _listInfo.ListDiaOc(MaDiaOc)[i].TinhTrang;

                    dsDiaOc.Add(m_diaoc);
                }
                _dataDiaOc.ItemsSource = dsDiaOc;
            }
            else
                MessageBox.Show("Kiểm Tra Lại Mã Địa Ốc", "Thông Báo");
        }

        public void ShowListDiaOc_MaKH(DataGrid _dataDiaOc, string MaKH, ref DataTable _dataTable)
        {
            if (_listInfo.ListDiaOc_MaKH(MaKH) != null)
            {
                List<DIAOC> dsDiaOc = new List<DIAOC>();
                for (int i = 0; i < _listInfo.ListDiaOc_MaKH(MaKH).Count; i++)
                {
                    DIAOC m_diaoc = new DIAOC();
                    m_diaoc.MaDiaOc = _listInfo.ListDiaOc_MaKH(MaKH)[i].MaDiaOc;
                    m_diaoc.MaKH = _listInfo.ListDiaOc_MaKH(MaKH)[i].MaKH;
                    m_diaoc.MaLoaiDiaOc = _listInfo.ListDiaOc_MaKH(MaKH)[i].MaLoaiDiaOc;
                    m_diaoc.SoNha = _listInfo.ListDiaOc_MaKH(MaKH)[i].SoNha;
                    m_diaoc.Duong = _listInfo.ListDiaOc_MaKH(MaKH)[i].Duong;
                    m_diaoc.Quan = _listInfo.ListDiaOc_MaKH(MaKH)[i].Quan;
                    m_diaoc.DienTichDat = _listInfo.ListDiaOc_MaKH(MaKH)[i].DienTichDat;
                    m_diaoc.DienTichSuDung = _listInfo.ListDiaOc_MaKH(MaKH)[i].DienTichSuDung;
                    m_diaoc.ViTri = _listInfo.ListDiaOc_MaKH(MaKH)[i].ViTri;
                    m_diaoc.HuongNha = _listInfo.ListDiaOc_MaKH(MaKH)[i].HuongNha;
                    m_diaoc.MoTa = _listInfo.ListDiaOc_MaKH(MaKH)[i].MoTa;
                    m_diaoc.GiaBan = _listInfo.ListDiaOc_MaKH(MaKH)[i].GiaBan;
                    m_diaoc.TinhTrang = _listInfo.ListDiaOc_MaKH(MaKH)[i].TinhTrang;

                    dsDiaOc.Add(m_diaoc);
                }
                _dataDiaOc.ItemsSource = dsDiaOc;
                _dataTable = _otherHandle.ToDataTable<DIAOC>(dsDiaOc);
            }
            else
                MessageBox.Show("Kiểm Tra Lại Mã Khách Hàng", "Thông Báo");
        }

        public void ShowDSKhachHangQCBang(DataGrid _dataKhachHang, ref DataTable _dataTable)
        {
            if (_listInfo.ListKhachHangQCBang() != null)
            {
                List<KHACHHANG> dsKhachHang = new List<KHACHHANG>();
                for (int i = 0; i < _listInfo.ListKhachHangQCBang().Count; i++)
                {
                    KHACHHANG _khachHangTemp = new KHACHHANG();

                    _khachHangTemp.MaKH = _listInfo.ListKhachHangQCBang()[i].MaKH;
                    _khachHangTemp.HoTen = _listInfo.ListKhachHangQCBang()[i].HoTen;
                    _khachHangTemp.NgaySinh = _listInfo.ListKhachHangQCBang()[i].NgaySinh;
                    _khachHangTemp.DiaChi = _listInfo.ListKhachHangQCBang()[i].DiaChi;
                    _khachHangTemp.Email = _listInfo.ListKhachHangQCBang()[i].Email;
                    _khachHangTemp.SoDT = _listInfo.ListKhachHangQCBang()[i].SoDT;

                    dsKhachHang.Add(_khachHangTemp);
                }
                _dataKhachHang.ItemsSource = dsKhachHang;
                _dataTable = _otherHandle.ToDataTable<KHACHHANG>(dsKhachHang);
            }
        }

        public void ShowDSKhachHangQCBao(DataGrid _dataKhachHang, ref DataTable _dataTable)
        {
            if (_listInfo.ListKhachHangQCBao() != null)
            {
                List<KHACHHANG> dsKhachHang = new List<KHACHHANG>();
                for (int i = 0; i < _listInfo.ListKhachHangQCBao().Count; i++)
                {
                    KHACHHANG _khachHangTemp = new KHACHHANG();

                    _khachHangTemp.MaKH = _listInfo.ListKhachHangQCBao()[i].MaKH;
                    _khachHangTemp.HoTen = _listInfo.ListKhachHangQCBao()[i].HoTen;
                    _khachHangTemp.NgaySinh = _listInfo.ListKhachHangQCBao()[i].NgaySinh;
                    _khachHangTemp.DiaChi = _listInfo.ListKhachHangQCBao()[i].DiaChi;
                    _khachHangTemp.Email = _listInfo.ListKhachHangQCBao()[i].Email;
                    _khachHangTemp.SoDT = _listInfo.ListKhachHangQCBao()[i].SoDT;

                    dsKhachHang.Add(_khachHangTemp);
                }
                _dataKhachHang.ItemsSource = dsKhachHang;
                _dataTable = _otherHandle.ToDataTable<KHACHHANG>(dsKhachHang);
            }
        }

        public void ShowDSKhachHangQCToBuom(DataGrid _dataKhachHang, ref DataTable _dataTable)
        {
            if (_listInfo.ListKhachHangQCToBuom() != null)
            {
                List<KHACHHANG> dsKhachHang = new List<KHACHHANG>();
                for (int i = 0; i < _listInfo.ListKhachHangQCToBuom().Count; i++)
                {
                    KHACHHANG _khachHangTemp = new KHACHHANG();

                    _khachHangTemp.MaKH = _listInfo.ListKhachHangQCToBuom()[i].MaKH;
                    _khachHangTemp.HoTen = _listInfo.ListKhachHangQCToBuom()[i].HoTen;
                    _khachHangTemp.NgaySinh = _listInfo.ListKhachHangQCToBuom()[i].NgaySinh;
                    _khachHangTemp.DiaChi = _listInfo.ListKhachHangQCToBuom()[i].DiaChi;
                    _khachHangTemp.Email = _listInfo.ListKhachHangQCToBuom()[i].Email;
                    _khachHangTemp.SoDT = _listInfo.ListKhachHangQCToBuom()[i].SoDT;

                    dsKhachHang.Add(_khachHangTemp);
                }
                _dataKhachHang.ItemsSource = dsKhachHang;
                _dataTable = _otherHandle.ToDataTable<KHACHHANG>(dsKhachHang);
            }
        }

        public void ShowBCPhieuThu(DataGrid _dataPhieuThu, int Thang, int Nam, ref DataTable _dataTable)
        {
            if (_listInfo.ListPhieuThuTungThang(Thang, Nam) != null)
            {
                List<PHIEUTHU> dsPhieuThu = new List<PHIEUTHU>();
                for (int i = 0; i < _listInfo.ListPhieuThuTungThang(Thang, Nam).Count; i++)
                {
                    PHIEUTHU m_phieuthu = new PHIEUTHU();

                    m_phieuthu.MaPhieuThu = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].MaPhieuThu;
                    m_phieuthu.MaDangKy = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].MaDangKy;
                    m_phieuthu.NgayThu = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].NgayThu;
                    m_phieuthu.SoTien = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].SoTien;
                    m_phieuthu.NgayHetHan = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].NgayHetHan;

                    dsPhieuThu.Add(m_phieuthu);
                }
                _dataPhieuThu.ItemsSource = dsPhieuThu;
                _dataTable = _otherHandle.ToDataTable<PHIEUTHU>(dsPhieuThu);
            }
        }

        public void ShowBCPhieuThu(DataGrid _dataPhieuThu, int Thang, int Nam)
        {
            if (_listInfo.ListPhieuThuTungThang(Thang, Nam) != null)
            {
                List<PHIEUTHU> dsPhieuThu = new List<PHIEUTHU>();
                for (int i = 0; i < _listInfo.ListPhieuThuTungThang(Thang, Nam).Count; i++)
                {
                    PHIEUTHU m_phieuthu = new PHIEUTHU();

                    m_phieuthu.MaPhieuThu = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].MaPhieuThu;
                    m_phieuthu.MaDangKy = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].MaDangKy;
                    m_phieuthu.NgayThu = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].NgayThu;
                    m_phieuthu.SoTien = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].SoTien;
                    m_phieuthu.NgayHetHan = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].NgayHetHan;

                    dsPhieuThu.Add(m_phieuthu);
                }
                _dataPhieuThu.ItemsSource = dsPhieuThu;
            }
        }

        public void ShowNhanVien(DataGrid _dataNhanVien)
        {
            if (_listInfo.ListNhanVien() != null)
            {
                List<NHANVIEN> dsNhanVien = new List<NHANVIEN>();
                for (int i = 0; i < _listInfo.ListNhanVien().Count; i++)
                {
                    NHANVIEN m_nhanvien = new NHANVIEN();
                    m_nhanvien.MaNhanVien = _listInfo.ListNhanVien()[i].MaNhanVien;
                    m_nhanvien.HoTenNV = _listInfo.ListNhanVien()[i].HoTenNV;
                    m_nhanvien.MaLoaiNV = _listInfo.ListNhanVien()[i].MaLoaiNV;

                    dsNhanVien.Add(m_nhanvien);
                }
                _dataNhanVien.ItemsSource = dsNhanVien;
            }
        }

        public void ShowLoaiNhanVien(DataGrid _dataLoaiNhanVien)
        {
            if (_listInfo.ListLoaiNhanVien() != null)
            {
                List<LOAINHANVIEN> dsLoaiNhanVien = new List<LOAINHANVIEN>();
                for (int i = 0; i < _listInfo.ListLoaiNhanVien().Count; i++)
                {
                    LOAINHANVIEN m_loainhanvien = new LOAINHANVIEN();
                    m_loainhanvien.MaLoaiNV = _listInfo.ListLoaiNhanVien()[i].MaLoaiNV;
                    m_loainhanvien.TenLoaiNV = _listInfo.ListLoaiNhanVien()[i].TenLoaiNV;

                    dsLoaiNhanVien.Add(m_loainhanvien);
                }
                _dataLoaiNhanVien.ItemsSource = dsLoaiNhanVien;
            }
        }

        //public void ShowBCPhieuThu_Test(ref DataTable _dataTable, int Thang, int Nam)
        //{
        //    if (_listInfo.ListPhieuThuTungThang(Thang, Nam) != null)
        //    {
        //        List<PHIEUTHU> dsPhieuThu = new List<PHIEUTHU>();

        //        for (int i = 0; i < _listInfo.ListPhieuThuTungThang(Thang, Nam).Count; i++)
        //        {
        //            PHIEUTHU m_phieuthu = new PHIEUTHU();

        //            m_phieuthu.MaPhieuThu = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].MaPhieuThu;
        //            m_phieuthu.MaDangKy = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].MaDangKy;
        //            m_phieuthu.NgayThu = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].NgayThu;
        //            m_phieuthu.SoTien = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].SoTien;
        //            m_phieuthu.NgayHetHan = _listInfo.ListPhieuThuTungThang(Thang, Nam)[i].NgayHetHan;

        //            dsPhieuThu.Add(m_phieuthu);
        //        }
        //        //_dataPhieuThu.ItemsSource = dsPhieuThu;
        //        _dataTable = _otherHandle.ToDataTable<PHIEUTHU>(dsPhieuThu);
        //    }
        //}
    }
}
